package pl.edu.agh.pros.proxy.logic.dao.common;

import java.util.Collection;

import com.google.appengine.api.datastore.Key;

/**
 * Base interface for data access operations
 * 
 * @param <T>
 */
public interface IAbstractDAO<T> {

	/**
	 * 
	 * @return transient collection of entities.
	 */
	public Collection<T> getAll();

	/**
	 * 
	 * @param key
	 * @return transient entity.
	 */
	public T getObjectById(Object key);

	/**
	 * 
	 * @param key
	 * @return transient entity.
	 */
	public T getObjectByKey(Key key);

	/**
	 * 
	 * @param queryString
	 * @param params
	 * @param values
	 * @return
	 */
	public Collection<T> getObjects(String queryString, String params, Object... values);

	/**
	 * 
	 * @param queryString
	 * @param params
	 * @param values
	 * @return
	 */
	public T getObject(String queryString, String params, Object... values);

	/**
	 * 
	 * @param keys
	 * @return
	 */
	public Collection<T> getObjects(Collection<?> keys);

	/**
	 * Makes object persistent.
	 * 
	 * @param object
	 */
	public T save(T object);

	/**
	 * Makes all objects persistent.
	 * 
	 * @param collection
	 */
	public Collection<T> saveAll(Collection<T> collection);

	/**
	 * Deletes object.
	 * 
	 * @param object
	 */
	public void delete(T object);

	/**
	 * Deletes object by key.
	 * 
	 * @param key
	 */
	public void deleteByKey(Object key);

	/**
	 * Deletes all entities of this type in database.
	 */
	public void deleteAll();

	/**
	 * Deletes entities from database.
	 */
	void deleteAll(final Collection<T> collection);

}